package org.gluedom.data;

import static com.google.common.base.Preconditions.checkArgument;

import java.util.Collection;
import java.util.Set;
import java.util.TreeSet;

interface PropertyContainer {
	public Iterable<Property> getProperties();

	public String getProperty(String name);

	static class Builder {
		final Set<Property> properties = new TreeSet<Property>(
				Property.PROPERTYHASH_COMPARATOR);

		Builder() {
		}

		void property(String name, String value) {
			property(Property.of(name, value));
		}

		void property(Property property) {
			assert property != null;
			properties.remove(property);
			properties.add(property);
		}

		void properties(Collection<Property> properties) {
			checkArgument(!properties.contains(null),
					"properties collection contains null value");
			this.properties.removeAll(properties);
			this.properties.addAll(properties);
		}
	}
}
